﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace postSale
{
    public class dataLib
    {
        public static data.postSaleDSTableAdapters.maintenanceCardTA maintenanceCardTA = new data.postSaleDSTableAdapters.maintenanceCardTA();
        public static data.postSaleDSTableAdapters.tasksTA tasksTA = new data.postSaleDSTableAdapters.tasksTA();
        public static data.postSaleDSTableAdapters.taskScheduleTA taskScheduleTA = new data.postSaleDSTableAdapters.taskScheduleTA();

        public static void DeletePendingTask(int scheduleId,byte status)
        {
            tasksTA.DeleteScheduleAndStatus(scheduleId, status);
        }

        public static data.postSaleDS.taskScheduleRow AddBlankTaskSchedule(data.postSaleDS.taskScheduleDataTable tbl, string taskId)
        {
            data.postSaleDS.taskScheduleRow scheduleRow;
            scheduleRow = tbl.NewtaskScheduleRow();
            scheduleRow.taskId = taskId;
            scheduleRow.type = (byte)postSale.myTypes.scheduleType.None;
            scheduleRow.warnMedia = (byte)postSale.myTypes.warningMedia.None;
            scheduleRow.status = (byte)common.CommonStatus.Enabled;
            scheduleRow.warnDay = 0;
            scheduleRow.repeatWarnDay = 0;
            scheduleRow.days = "";
            scheduleRow.months = "";
            scheduleRow.recipients = "";
            scheduleRow.createdBy = CommonTypes.Settings.sysLoginInfo.UserId;
            tbl.AddtaskScheduleRow(scheduleRow);
            return scheduleRow;
        }

        public static data.postSaleDS.maintenanceCardRow GetMaintenanceCard(string type, string cardNo)
        {
            data.postSaleDS.maintenanceCardDataTable tbl = maintenanceCardTA.GetDataByCardNo(type, cardNo); ;
            if (tbl.Count > 0) return tbl[0];
            return null;
        }
        //public static data.postSaleDS.maintenanceCardRow GetMaintenanceCardBySeri(string itemSeri)
        //{
        //    data.postSaleDS.maintenanceCardDataTable tbl = maintenanceCardTA.GetByItemSeri(itemSeri); ;
        //    if (tbl.Count > 0) return tbl[0];
        //    return null;
        //}
    }
}
